package com.me.chat.controller.bis.chat;

import com.me.chat.pojo.chat.ChatLately;
import com.me.chat.pojo.chat.ChatMessage;
import com.me.chat.pojo.chat.qo.ChatMessageQO;
import com.me.chat.pojo.suport.ResultBean;
import com.me.chat.service.chat.ChatMessageService;
import com.me.chat.util.stauts.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 聊天消息列表的控制层
 * @Authhor: qiu
 * @Date: 2021/12/5 12:28 上午
 */
@Slf4j
@RestController
@RequestMapping("/res/chat_message")
public class ChatMessageController {

    @Autowired
    ChatMessageService chatMessageService;

    /**
     * 点对点聊天消息查询
     * @param chatMessageQO 其中的userId 参数不需要传递，传递了也会被覆盖
     * @param current 非必要字段 默认值为1
     * @param size 非必要字段 默认值为10
     * @return
     */
    @GetMapping("/single_search")
    public ResultBean<List<ChatMessage>> getSingleSearch(ChatMessageQO chatMessageQO,
        @RequestParam(value = "current",required = false,defaultValue = "1") int current,
        @RequestParam(value = "size",required = false,defaultValue = "15") int size) {

        List<ChatMessage> chatMessages = chatMessageService.selChatSingleMessage(chatMessageQO, current, size);
        return new ResultBean<>(StatusCode.SUCCEED,chatMessages,"点对点消息查询");
    }
}
